import sys
from pathlib import Path
parent_dir = str(Path(__file__).resolve().parent.parent)
print(parent_dir,"parent_dir")
sys.path.append(parent_dir)
from main import ai_chat_history

MAX_MEMORY_LEN = 5
histories = []
PROMPT = "你是一名学时丰富的科学家，请对用户的提问作出科学严谨的回答"

def get_user_content():
  return input("请输入您的问题：")

user_content = get_user_content()

while user_content != "exit":
  histories.append({
    "role":"user",
    "content":user_content
  })
  new_histories = histories[-MAX_MEMORY_LEN:]
  print(new_histories,"new_histories")
  new_histories.insert(0,{
    "role":"system",
    "content":PROMPT
  })
  response_text = ai_chat_history(new_histories)
  print(response_text)
  histories.append({
    "role":"user",
    "content":response_text
  })
  user_content = get_user_content()

  